package com.example.demo.controller;

import com.example.demo.Result;
import com.example.demo.pojo.sys.SysResources;
import com.example.demo.service.SysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.security.Principal;
import java.util.List;

@RestController
@RequestMapping("/res")
public class SysUserController {
    @Autowired
    private SysUserService sysUserService;

    @RequestMapping("/get")
    public Result getResources(Principal principal) {
        String username = principal.getName();
        List<SysResources> list = sysUserService.getResources(username);
        return Result.ok("200","success", list);
    }
    @RequestMapping("/getName")
    public Result getName(Principal principal) {
        String username = principal.getName();
        return Result.ok("200","success", username);
    }
}
